package org.gten.gegedexin.controller;

import com.alibaba.fastjson.JSONArray;
import org.gten.gegedexin.Data.QueryInformation;
import org.gten.gegedexin.service.DeleteMail;
import org.gten.gegedexin.service.ReadMail;
import org.gten.gegedexin.service.ReadMailList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DelectMailController {
    @Autowired
    DeleteMail deleteMail;
    @Autowired
    ReadMailList readMailList;
    @RequestMapping("/DelMail")
    @CrossOrigin
    public void DelMail(String mailID){
        deleteMail.delmail(mailID);
        readMailList.readList(readMailList.getUser());
    }

    //  返回回收站邮件页数
    @RequestMapping("/getRecycleBin")
    @CrossOrigin
    public JSONArray getRecycleBin(String userID, QueryInformation queryInformation){
        readMailList.readList(userID);
        return readMailList.recyclePage(queryInformation.getPage());
    }

    @RequestMapping("/Restore")
    public void Restore(String mailID){
        deleteMail.restoreMail(mailID);
        readMailList.readList(readMailList.getUser());
    }

//    //  返回回收站指定页的邮件列表
//    @RequestMapping("/getRecycleBinPage")
//    @ResponseBody
//    @CrossOrigin
//    public JSONArray getRecycleBinPage(int page){
//
//    }
}
